<?php

include "../../lib/start.php";

check_session();
check_permission(ADM_PERM);

$anno = $_SESSION['__current_year__']->get_ID();

$classe = $_POST['cls'];
$materia = $_POST['mat'];
$docente = $_POST['doc'];

header("Content-type: text/plain");
if($materia != "coord")
	$upd = "UPDATE cdc SET id_docente = $docente WHERE id_materia = $materia AND id_anno = $anno AND id_classe = $classe";
else
	$upd = "UPDATE cdc SET coordinatore = '1' WHERE id_docente = $docente AND id_anno = $anno AND id_classe = $classe";
try{
	$db->executeUpdate($upd);
} catch (MySQLException $ex){
	print "ko;".$ex->getQuery().";".$ex->getMessage();
	exit;
}
print "ok;$upd";
exit();
?>